package top.linyuxb.lycloud.rpc.starter.aop;

import top.linyuxb.lycloud.rpc.starter.annotation.LyRpcServer;
import top.linyuxb.lycloud.rpc.starter.properties.LyRpcClientProperties;

import java.lang.reflect.Proxy;

/**
 * Created by Intellij IDEA.
 *
 * @Author: linyuxb
 * @Date: 2024/5/31 15:44
 * @Desc:
 */
public class RpcSession {
    /**
     * 获取代理类
     *
     * @param classz                目标接口
     * @param lyRpcServer           类注解参数
     * @param lyRpcClientProperties 配置参数
     * @return
     */
    public static Object getServer(Class<?> classz, LyRpcServer lyRpcServer, LyRpcClientProperties lyRpcClientProperties) {
        return Proxy.newProxyInstance(
                classz.getClassLoader(),
                new Class<?>[]{classz},
                new MyInvocationHandlerRpc(classz, lyRpcServer, lyRpcClientProperties));
    }

}
